package com.zengqingfa.springboot.validation.demo.controller;

import com.zengqingfa.springboot.validation.demo.entity.TestConstructor;
import com.zengqingfa.springboot.validation.demo.entity.UserDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.Min;


@RestController
@RequestMapping("/user")
@Slf4j
public class UserRest {

    @PostMapping("/create")
    public String saveUser(@RequestBody @Valid UserDto user) {
        log.info("user:{}", user);
        return "save success1";
    }

    @PostMapping("/create2")
    public String saveUser2(@RequestBody @Validated UserDto user) {
        log.info("user:{}", user);
        return "save success2";
    }

    @PostMapping("/update")
    public String updateUser(@RequestBody @Validated UserDto user) {
        log.info("user:{}", user);
        return "update success";
    }

    @PostMapping("/create1")
    public String create1(@RequestBody TestConstructor constructor) {
        log.info("user:{}", constructor);
        return "create1 success";
    }


}
